//
//  NHHomeBaseViewController.m
//  LZNeiHan
//
//  Created by 梁梓烽 on 16/10/1.
//  Copyright © 2016年 liangzifeng. All rights reserved.
//

#import "NHHomeBaseViewController.h"
#import "NHBaseRequest.h"
#import "NHHomeListRequest.h"
#import "UIViewController+loading.h"

@interface NHHomeBaseViewController ()
@property(nonatomic,strong)NSString *url;
@property(nonatomic,strong)NHBaseRequest *request;
@end

@implementation NHHomeBaseViewController


#pragma mark -构造方法
/** 初始化 */
-(instancetype)initWithUrl:(NSString *)url
{
    if (self  = [super init]) {
        self.url = url;
    }
    
    return  self;
}


/** 初始化 */
-(instancetype)initWithRequest:(NHBaseRequest *)request
{
    if (self  =[super init]) {
        self.request = request;
    }
    
    return  self;
}


#pragma mark -view  生命周期
-(void)viewDidLoad
{
    [super viewDidLoad];
     //
    self.needCellSepLine  =NO;
    
    self.showRefreshIcon  = YES;
    
    self.refreshType  = NHBaseTableVcRefreshTypeRefreshAndLoadMore;
    
    //

    if (self.url.length) {
        NHHomeListRequest  *request =[[NHHomeListRequest alloc]nh_request];
        self.request = request;
        request.url = self.url;
        [self loadData];
        
    }
    else
    {
        [self loadData];
    }
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    //
}




-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    //
}


-(void)loadData
{
    if (!self.request) return;
    [self.request nh_sendRequestWithComplemation:^(BOOL success, id response, NSString *message) {
        
        if (success) {
            [self hideLoadingView];
            
            
            [self endRefreshIconAnimation];
            
            
            
        }
    }];
}

@end
